package com.thredpooldemo.config;

import org.dromara.dynamictp.core.DtpRegistry;
import org.dromara.dynamictp.core.executor.DtpExecutor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 定时器demo
 * @author tyg
 * @date 2021-04-15 9:50
 */
@Component
public class DemoTask {

    @Resource
    private DtpConfig dtpConfig;

    @Scheduled(fixedDelay = 2000)
    public void run(){
        DtpExecutor dtpExecutor11 = DtpRegistry.getDtpExecutor("dtpExecutor1");
        System.out.println(
                "当前线程名称：" + Thread.currentThread().getName() +
                        "核心线程数量：" + dtpExecutor11.getCorePoolSize() +
                        "最大线程数量：" + dtpExecutor11.getMaximumPoolSize()
        );
        System.out.println("nacos:->>>" + dtpConfig.getExecutors().get(0).getCorePoolSize());
    }
}
